﻿using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;

namespace WeBlog.Core.Managers
{
    public class ThemeManager
    {
        private readonly DirectoryInfo _rootDirectory;

        public ThemeManager(DirectoryInfo rootDirectory)
        {
            _rootDirectory = rootDirectory;
        }
        
        public IEnumerable<SelectListItem> Themes(string selectedValue)
        {
            foreach (var theme in _rootDirectory.EnumerateDirectories())
            {
                yield return new SelectListItem
                {
                    Selected = (theme.Name == selectedValue),
                    Text = theme.Name,
                    Value = theme.Name
                };
            }
        }
    }
}